package day13;

/**
 * 字符串中的字符排序
 */
public class ArrayDemo2 {
    public static void main(String[] args) {
        String s = "daefg";
        char[] chs = s.toCharArray();
        System.out.println(s);
        System.out.println(chs);

        bubbleSort(chs);
        String result = String.valueOf(chs);
        System.out.println(result);
    }

    public static void bubbleSort(char[] chs) {
		for (int x = 0; x < chs.length - 1; x++) {
			for (int y = 0; y < chs.length - 1 - x; y++) {
				if (chs[y] > chs[y + 1]) {
					char temp = chs[y];
					chs[y] = chs[y + 1];
					chs[y + 1] = temp;
				}
			}
		}
	}
}
